# -*- coding: utf-8 -*-
# @Time : 2021/9/17 14:04
# @Author : WANGCHENYI
# @Email : wcy@gmail.com
# @File : MRYX-ST-KBTJ-01.py
# @Project : mryx_test
"""查看商品详情"""
from appium import webdriver
from time import sleep
from selenium.webdriver.support.ui import WebDriverWait
desired_capabilities={
    "platformName":"Android",
    "deviceName":"127.0.0.1:62001",
    "platformVersion":"7.1.2",
    "appPackage":" cn.missfresh.application",
    "appActivity":"cn.missfresh.module.main.view.MainActivity",
    "noReset":True
}
driver=webdriver.Remote("http://localhost:4723/wd/hub",desired_capabilities)
#点击口碑推荐榜
driver.find_element_by_id("cn.missfresh.application:id/top_image").click()
#点击商品
sleep(2)
driver.find_element_by_xpath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View[2]/android.view.View[1]/android.view.View[2]/android.view.View[1]').click()
#向下滑动
size=driver.get_window_size()
sleep(2)
height=size.get("height")
width=size.get("width")
start_y=height*0.9
end_y=height*0.5
start_x=end_x=width*0.5
driver.swipe(start_x,start_y,end_x,end_y)
#点击详情页面
driver.find_element_by_xpath('//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.widget.ScrollView[1]').click()

sleep(3)
driver.quit()

